﻿﻿

<!--********************* Part1:Jsp Head *********************-->

<%@ page contentType="text/html;charset=UTF-8"%>  
<%@ include file="/framework/head.jsp"%>

<!--********************* Part2:Java Code *********************-->
<%
    GetStatisticSearchEvent event = (GetStatisticSearchEvent)context.getSessionValue("GetStatisticSearchEvent");
	ObjectList list = GetStatistic.fetch().detailqueryGroupForHour(con,event);
	ObjectList warehouseList = (ObjectList)context.getSessionValue("WarehouseListDetail");
    
    String currentWarehouseCode = loginInfo.getLoginWarehouseCode();
%>
<!--********************* Part3:JavaScript Code ***************-->
<!--start 客户端脚本区域-->
<%@page import="system.base.Warehouse"%>
<%@page import="system.LoginContext"%>
<script language=javascript>

var list_code = "listGetStatistic";

function doSearch()
{
    var startHour=document.getElementById("startHour").selectedIndex;
    if(startHour <10){
        startHour=" 0"+startHour+":00:00";
        }else{ 
        startHour=" "+startHour+":00:00";   
        }    
    var endHour=(document.getElementById("endHour").selectedIndex);
    if(endHour <10){
        endHour=" 0"+endHour+":59:59";
        }else{ 
        endHour=" "+endHour+":59:59";  
        }  

	var warehouseCodes = $.jstree._reference("#warehouseLevel").get_checked();
    var warehouseList = new Array();
     var i = 0;
     $.each(warehouseCodes, function() {
	           warehouseList[i] =($(this).attr("id"));
	           i++;
	 });

    SetValue("WarehouseCodes",warehouseList); 

	SetValue("s_GetCustomerCode",GetValue("i_GetCustomerCode")); //领料单位

	SetValue("s_OutType",GetValue("i_OutType")); //出库类型

    SetValue("s_BalanceFlag",GetValue("i_BalanceFlag")); //结算状态

    SetValue("s_StartOutTime",GetValue("i_StartOutTime") ==""?"":GetValue("i_StartOutTime")+startHour); //出库开始日期
    
    SetValue("s_EndOutTime",GetValue("i_EndOutTime") ==""?"":GetValue("i_EndOutTime")+endHour); //出库结束日期
    
    SetValue("s_IsNormal",GetValue("i_IsNormal")); //是否正式产品

    SetValue("s_BalanceMode",GetValue("i_BalanceMode")); //结算模式
    
    SetValue("s_PositionCode",GetValue("i_PositionCode")); //货位CODE

	doCommonSearch();
}

function doExport()
{
    SetAction("exportGetStatistic");
    frm.submit();
}

function doDetailExport(customerCode)
{
    SetAction("exportDetailStatistic");
    SetValue("s_GetCustomerCode",customerCode); //领料单位
    //document.getElementById("s_GetCustomerCode").value = customerCode;
    frm.submit();
}

/*
function bizViewOutHead(id)
{
	viewWin("<%=Config.getSrv()%>?action_code=viewOutHead&Id="+id);
}

function doDelete()
{
	if(!hasChooseRadio("ids"))
	{
		bizMessage("删除","出库单主表");
		return false;
	}
	if(!bizConfirm("删除","出库单主表")) return false;
	SetAction("deleteOutHead");
	frm.submit();
}

function doToAdd()
{
	SetAction("toAddOutHead");
	frm.submit();
}

function doToUpdate()
{
	if(!checkOne("ids")) 
	{
		bizMessage("修改","出库单主表");
		return false;
	}
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toUpdateOutHead");
	frm.submit();
}
function doToCopy()
{
	if(!checkOne("ids")) 
	{
		bizMessage("复制","出库单主表");
		return false;
	}
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toCopyOutHead");
	frm.submit();
}
*/
key_InitDefault();
key_RegSubmitHandler(doSearch);
</script>
<script type="text/javascript" src = "<%=Config.getWebPath()%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src = "<%=Config.getWebPath()%>/js/jquery.jstree.js"></script>
<link type="text/css" rel="stylesheet" href="<%=Config.getWebPath()%>/css/themes/default/style.css"/>
<script type="text/javascript">
	   $(function() {
		    $("#warehouseLevel").jstree({
		        "plugins" : [ "themes", "html_data", "checkbox", "ui" ]
		       
		    });
		    
		    var checkedWarehouseCodes = "<%=event.getWarehouseTreeCodes()[0]%>";
		    
		    if(checkedWarehouseCodes == "") checkedWarehouseCodes = "00";
		    
		    var arrayCheckedWarehouseCodes = checkedWarehouseCodes.split(",");
		   
		   		  	
		  	var checkSel = function(ary, val) {
		  		for(var i=0; i<ary.length; i++) {
		  			if(ary[i] == val) {
		  				return true;
		  			}
		  		}
		  		
		  		return false;
		  	}
		    <%if(context.getString("isFirstVisit").equals("false")){ %>
			  	$("#warehouseLevel li").each(
			  		function() 	{
			  			if(checkSel(arrayCheckedWarehouseCodes, $(this).attr("id"))) {
			  				$.jstree._reference("#warehouseLevel").check_node($(this));
			  			} 	  			
			  		}
			  	);
		  	<%}%>
		  
		});
			
</script>

<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->
<form id=frm action="<%=Config.getSrv()%>" method="post">
<input type=hidden name="action_code" value="">
<input type=hidden name="Id" value="">
<input type=hidden name=sortOrder value="1">

<!--查询条件保留区域-->
<input type=hidden name="WarehouseCodes" value="<%=event.getWarehouseTreeCodes()[0]%>" > 

<input type=hidden name="s_GetCustomerCode" id="s_GetCustomerCode" value="<%=event.getGetCustomerCode()%>"> <!--领料单位-->

<input type=hidden name="s_OutType" value="<%=event.getOutType()%>"> <!--出库类型-->

<input type=hidden name="s_BalanceFlag" value="<%=event.getBalanceFlag()%>"> <!--结算状态-->

<input type=hidden name="s_StartOutTime" value="<%=event.getStartOutTime()%>"> <!--出库开始日期-->

<input type=hidden name="s_EndOutTime" value="<%=event.getEndOutTime()%>"> <!--出库结束日期-->

<input type=hidden name="s_IsNormal" value="<%=event.getIsNormal()%>"> <!--是否正式产品-->

<input type=hidden name="s_BalanceMode" value="<%=event.getBalanceMode()%>"> <!--结算模式-->

<input type=hidden name=s_PositionCode value="<%=event.getPositionCode()%>"> <!--选择的货位code-->



<%@ include file="/framework/list_head.jsp"%>

<br>
<!--********************* Part5:Search Area ***************-->
<%=uiSearchStart%>>
<%
	int key_tab = 1 ;
%>


	<%=uiSearchInputTR%>>
        <%=uiSearchInputTDHead%>>
              仓库选择：
            <div id="warehouseLevel" style="background-color: DEE4E9">
				<%=Warehouse.getWarehouseTree(warehouseList,event.getWarehouseCodes())%>
			</div>
        </td>       
    </tr>

	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
              领料单位：
            <%=SelectManager.viewCustomerSelect(con, currentWarehouseCode, "i_GetCustomerCode",event.getGetCustomerCode(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
            &nbsp;&nbsp;&nbsp;&nbsp;出库类型：
            <%=SelectManager.viewOutTypeSelect(con,"i_OutType",event.getOutType(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>  
            &nbsp;&nbsp;&nbsp;&nbsp;结算状态：
            <%=SelectManager.viewBalanceOrNoSelect("i_BalanceFlag",event.getBalanceFlag(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
        </td>       
    </tr>

	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
              出库时间：
            <%=framework.custom.UIManager.generateDateInput("i_StartOutTime", "")%> 
              <select id="startHour" >
              <%for(int i=0;i<24;i++){ %>
                <option><%=i %></option>
                <%} %>
              </select>      
            	至 
            <%=framework.custom.UIManager.generateDateInput("i_EndOutTime", "")%>
                          <select id="endHour">
                <option>1</option>
                <option>2</option>
                <option>3</option>
                <option>4</option>
                <option>5</option>
                <option>6</option>
                <option>7</option>
                <option>8</option>
                <option>9</option>
                <option>10</option>
                <option>11</option>
                <option>12</option>
                <option>13</option>
                <option>14</option>
                <option>15</option>
                <option>16</option>
                <option>17</option>
                <option>18</option>
                <option>19</option>
                <option>20</option>
                <option>21</option>
                <option>22</option>
                <option>23</option>
                <option selected="selected">24</option>
              </select> 
            &nbsp;&nbsp;&nbsp;&nbsp;是否正式产品：
            <%=SelectManager.viewYesOrNoSelect("i_IsNormal",event.getIsNormal(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
        </td>		
	</tr>

	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
              结算模式：
            <%=SelectManager.viewYKorMD("i_BalanceMode",event.getBalanceMode(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
          仓库货位：
            <%=SelectManager.viewWarehousePosition(con,loginInfo.getLoginWarehouseCode(),"i_PositionCode",event.getPositionCode(),false,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++),event.getWarehouseCodes())%>
			&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="查询" class="buttons" onclick="doSearch();return false;">&nbsp;<input type="button" value="清空" class="buttons" onclick="doClearEvent();return false;">
		</td>
	</tr>

<%=uiSearchEnd%>

<!--列表标题-->
<%=UIManager.addListHeadTitle("领料情况统计")%>

<!--********************* Part6:List Area ***************-->

<%=uiListStart%>>

<%@ include file="/framework/list_foot.jsp"%>

<%
	int index = 1 ;
%>	
	<%=uiListHeadTR%>>

        <%=UIManager.addListHead("仓库",index++)%>

		<%=UIManager.addListHead("领料单位",index++)%>
        
        <%=UIManager.addListHead("总金额",index++)%>
        
        <%=UIManager.addListHead("",index++)%>
        
	<%=uiListHeadTREnd%>>
	
	<!--data-->
<%
//郑斌
String result = String.valueOf(list.get(list.size()-1)== null ? "0" : list.get(list.size()-1) );
list.remove(list.size()-1);
double temp2 = Double.parseDouble(result);//benny 03
double resultMoney = 0;
resultMoney = resultMoney + temp2;//郑斌04
//郑斌
double countMoney = 0;//郑斌 01
double countPageMoney = 0;//郑斌 02
	for(int i=0;i<list.size();i++)
	{
	    UniversalRow row = (UniversalRow)list.get(i);
%>
	<%=uiListDataTR[i%2]%> align=center>
    
        <%=uiListDataTD%>><%=Warehouse.getNameByCode(con,row.getString(1))%></td>
    
        <%=uiListDataTD%>><%=row.getString(3)%></td>
        
        <%=uiListDataTD%>><%= StringUtil.showPrice(row.getString(4))%></td>
        
        <%=uiListDataTD%>><input type=button value="导出" class="buttons" onclick="doDetailExport('<%=row.getString(2)%>');return false;"></td>
    <%
    double temp = Double.parseDouble(row.getString(4));//benny 03
    countPageMoney = countPageMoney + temp;//郑斌04
    %>
  	</tr>    
<%	
	}
%>  

<%=uiListDataTR[0]%> align=center>    
<%=uiListDataTD%> colspan='4' align = right >
            <b><%="当前页总金额:"+framework.core.StringUtil.showPrice(""+countPageMoney)%></b>
    </td>
</tr>
<%=uiListDataTR[0]%> align=center>
<%=uiListDataTD%> colspan='4' align = right >
            <b><%="当前条件总金额:"+framework.core.StringUtil.showPrice(""+resultMoney)%></b>
    </td>
</tr>

<%@ include file="/framework/list_foot2.jsp"%>

<%=uiListEnd%>


<!--********************* Part7:Action Area ***************-->
<%=uiCommandStart%>>
	<%=uiCommandTR%>>
		<%=uiCommandTD%>>
        <!--
		<input type=button value="   添加   " class="buttons" onclick="doToAdd();return false;">
		
		<input type=button value="   复制   " class="buttons" onclick="doToCopy();return false;">
		
		<input type=button value="   修改   " class="buttons" onclick="doToUpdate();return false;">
		<input type=button value="   删除   " class="buttons" onclick="doDelete();return false;">
		-->
        <input type=button value="   导出   " class="buttons" onclick="doExport();return false;">
        </td>
	</tr>	
<%=uiCommandEnd%>
</form>


<%@ include file="/framework/foot.jsp"%>

<!--
	Author    :Wing
	FileName  :/system/base/OutHeadList.jsp
-->
